package com.bjpowernode.controller;

import com.bjpowernode.entity.Economics;
import com.bjpowernode.service.EconomicsService;
import com.bjpowernode.service.StatisticsService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 * 处理对账相关业务
 *
 * @author 刘逸晖
 */
@RequestMapping
public class ReconciliationController {

    /**
     * 处理统计相关业务
     */
    private StatisticsService statisticsService;

    /**
     * 处理收支记录相关的业务
     */
    private EconomicsService economicsService;

    /**
     * 本月对账，就是查询本月余额
     *
     * @return 模型和试图
     */
    @RequestMapping(value = "/myWeb/reconciliation.do")
    public ModelAndView find() {
        //查询收支集合
        List<Economics> economics = this.economicsService.selectAllEconomics();

        //统计本月余额
        Integer balance = this.statisticsService.selectBalanceOfMonth();

        ModelAndView modelAndView = new ModelAndView();

        modelAndView.addObject("list", economics)
                .addObject("balance", balance)
                .setViewName("reconciliation");

        return modelAndView;
    }

    public StatisticsService getStatisticsService() {
        return statisticsService;
    }

    public void setStatisticsService(StatisticsService statisticsService) {
        this.statisticsService = statisticsService;
    }

    public EconomicsService getEconomicsService() {
        return economicsService;
    }

    public void setEconomicsService(EconomicsService economicsService) {
        this.economicsService = economicsService;
    }
}
